Jx.declare('Jx.lib.Unit', {

	$accessors: {

		value: undefined

	},

	$actions: [

		'initialize'

	],

	constructor: function(){

		this.$super();

		this.initialize();

		if (arguments.length){

			this.setValue.apply(this, arguments);

		}

	},

	allowSetValue: function(){

		return false;

	},

	onSetValue: function(operation){

		this.set('value', operation.value);

	},

	valueOf: function(){

		return this.getValue.apply(this, arguments);

	},

	toString: function(){

		var value = this.getValue.apply(this, arguments);

		return Jx.isNumber(value) ?

			value.toString()

			:

			Jx.isString(value) ?

				value

				:

				'';

	},

	compare: function(value){

		value = String(value);

		var me = this.toString();

		return me == value ?

			0

			:

			me < value ?

				-1

				:

				1;

	}

});
